import request from '../request'
import request_sso from '../request-sso'
import Axios from "axios";

export default {
    login(userName: string, passWord: string) {
        return request_sso({ // 认证中心登录
            url: '/sso/doLogin',
            method: 'post',
            params: {
                'name': userName,
                "pwd": passWord
            }
        })
    },
    // 检查当前是否已经登录，如果已登录则直接开始跳转，如果未登录则等待用户输入账号密码
    getRedirectUrl(redirect: any, mode: string) {
        return request_sso({ // 认证中检查当前是否已经登录
            url: '/sso/getRedirectUrl',
            method: 'post',
            params: { redirect: redirect, mode: mode }
        })
    },


    goSsoAuthUrl(url: string) {
        return request({ //获取认证中心登录地址
            url: '/sso/getSsoAuthUrl',
            method: 'post',
            params: {
                clientLoginUrl: url
            }
        })
    },
    doLoginByTicket(ticket: string) {
        return request({ //ticket登录
            url: '/sso/doLoginByTicket',
            method: 'post',
            params: {
                ticket: ticket
            }
        })
    },
    checkLogin() {
        return request({ //检查是否登录
            url: '/isLogin',
            method: 'post'
        })
    },
    myInfo() {
        return request({ //获取登录用户信息
            url: '/sso/myInfo',
            method: 'post'
        })
    },
    logOut() {
        return request({ //注销
            url: '/sso/logout',
            method: 'post'
        })
    },
    //去重jnrkdsj session
    jnrkdsjLogOut(data: any) {
        return request({
            url: ` https://172.20.88.210:8081/jnrkdsj/jsp/main/loginout.jsp`,
            method: 'post',
            data: data
        })
    },


    // 获取菜单信息
    // getMenuList(cdbh: string) {
    //     return request({ //获取认证中心登录地址
    //         url: '/cdxx/getCdxxTreeByJsAndXt',
    //         method: 'post',
    //         data: {
    //             cdbh: cdbh
    //         }
    //     })
    // },
    getMenuList(cdbh: string) {
        return request({ //获取认证中心登录地址
            url: '/jscdGlxx/getCdxxTreeByJsAndXt',
            method: 'post',
            data: {
                cdbh: cdbh
            }
        })
    },
    getQueryYhDwxx(yhm: string) {
        return request({ //用户所属单位信息查询接口
            url: '/yhdwGlxx/queryYhDwxx',
            method: 'post',
            data: {
                yhm: yhm
            }
        })
    },
    ssoApi(yhmDwbm: Object) {
        return request_sso({ //切换用户单位
            url: '/sso/currentdwxx',
            method: 'post',
            params: yhmDwbm
        })
    },
    updateYhData(yhdata: Object) {
        return request({ //切换用户单位
            url: '/yhxx/updateYhData',
            method: 'post',
            data: yhdata
        })
    },
    getYhjsxxByYhm(yhm: string) {
        return request({ //获取当前用户所属角色信息
            url: '/yhxtjsGlxx/getYhjsxxByYhm',
            method: 'post',
            params: {
                yhm: yhm
            }
        })
    },
    getcurrentroledm(yhm: string, jsbh: string) {
        return request_sso({ //切换角色信息
            url: '/sso/currentroledm',
            method: 'post',
            params: {
                yhm: yhm,
                jsbh: jsbh
            }
        })
    },
    updateYhData1(yhdata: { yhm: string }) {
        return request({ //切换用户单位
            url: '/yhxx/updateYhData',
            method: 'post',
            data: {
                yhm: yhdata.yhm
            }
        })
    },
}